package com.vf.admin.miaodong.controller;

import com.vf.admin.common.BaseController;
import com.vf.admin.common.Constants;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.dao.AfterOrderDao;
import com.vf.admin.miaodong.entity.AppOrder;
import com.vf.admin.miaodong.service.AfterOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 订单管理
 */
@Controller
@RequestMapping("/after/order")
public class AfterOrderController extends BaseController {

    @Autowired
    AfterOrderService afterOrderService;

    /**
     * 获取所有订单
     */
    @RequestMapping("/list")
    public String getAllUser(SplitPageBean splitPage, String nick, Integer type,Integer status,String phone,String ordernum,String startdate, String enddate) {
        Map<String, Object> map = new HashMap<>();
        map.put("nick", nick);//用户名称
        map.put("phone", phone);//用户电话
        map.put("type", type);//订单类型  1支付宝  2微信
        map.put("status", status);//状态  1待付款  2已付款
        map.put("ordernum", ordernum);//订单号
        map.put("startdate", startdate);
        map.put("enddate", enddate);
        Map<Integer,String> statesMap = Constants.getOrderTypeMap();
        Map<Integer, String> userStatusMap = Constants.getOrderStatusMap();
        List<AppOrder> maps = afterOrderService.findList(map, splitPage);
        request.setAttribute("nick",nick);
        request.setAttribute("phone",phone);
        request.setAttribute("type",type);
        request.setAttribute("status",status);
        request.setAttribute("ordernum",ordernum);
        request.setAttribute("statesMap",statesMap);
        request.setAttribute("userStatusMap",userStatusMap);
        request.setAttribute("startdate",startdate);
        request.setAttribute("enddate",enddate);
        request.setAttribute("list",maps);
        request.setAttribute("splitPage",splitPage);
        return this.sucess("/web/after/order/list");
    }


}
